﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Skimpt3;
using Skimpt3.Plugins.Interface;
using System.Drawing;
using System.Windows.Forms;

namespace LocalPlugin
{
    public class LocalPlugin : IUploaderInterface
    {
        public string Name
        {
            get { return "LocalHost"; }
        }

        public string FormURL
        {
            get { return "http://10.0.0.4/skimpt.php"; }
        }

        public string FileBoxName
        {
            get { return "file"; }
        }

        private string strFileUrl = null;
        public string FileUrl
        {
            get { return strFileUrl; }
        }
 
        private string strThumbUrl = null;
        public string ThumbUrl
        {
            get { return strThumbUrl; }
        }

        private Image imgImage = null;
        public Image Image
        {
            get { return imgImage; }
            set { imgImage = value; }
        }

        private string strFileName = null;
        public string FileName
        {
            get { return strFileName; }
            set { strFileName = value; }
        }

        [STAThread]
        public void Upload()
        {
            Skimpt3.PostFile post = new Skimpt3.PostFile(FormURL, FileName);

            Skimpt3.InputBox input = new Skimpt3.InputBox("What do you want to name the file?");
            DialogResult res = input.ShowDialog();

            if (res == DialogResult.OK)
            {
                post.AddFormElement("File name", input.Result);
            }

            post.AddFormElement("submit", "Submit");
            post.AddFormElement("text", "HAI");
            post.FileBoxName = FileBoxName;
            post.ContentMIMEType = "image/jpeg";

            try
            {
                post.Send(Image);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            Console.WriteLine(post.Response);
        }
    }
}
